import { defineStore } from "pinia";
export const useFacilityStore = defineStore(
  "facility",
  () => {
    const produceList = [
      { name: "材料1", status: "s0", Model: "M101" },
      { name: "生产线2", status: "s1", Model: "M102" },
      { name: "生产线3", status: "s2", Model: "M103" },
      { name: "生产线4", status: "s2", Model: "M104" },
      { name: "生产线5", status: "s2", Model: "M105" },
    ];
    const storageList = [
      { name: "库位1", unit: "1200", Model: "S101" },
      { name: "库位2", unit: "100", Model: "S102" },
      { name: "库位3", unit: "65", Model: "S103" },
    ];
    const useList = [
      { name: "使用1", Model: "U101", status: "s0" },
      { name: "使用2", Model: "U102", status: "s1" },
      { name: "使用3", Model: "U103", status: "s2" },
    ];
    return { produceList, storageList, useList };
  },
  // TODO: 持久化
  {
    // 配置持久化
    persist: {
      // 调整为兼容多端的API
      storage: {
        setItem(key, value) {
          uni.setStorageSync(key, value);
        },
        getItem(key) {
          return uni.getStorageSync(key);
        },
      },
      paths: ["controls_list"],
    },
  }
);
